home *** CD-ROM | disk | FTP | other *** search
/ Apple Macintosh CD: Powe…osh 6100/7100/8100 Series / Apple Macintosh CD - Power Macintosh 6100, 7100, 8100 series.7z / Apple Macintosh CD - Power Macintosh 6100, 7100, 8100 series.bin / Power Macintosh Demo Apps / Segue / DEMO / demo.inc next >
Text File  |  1994-01-12  |  10KB  |  255 lines

  1. /*
  2. **     demo.inc 
  3. **
  4. **     Window declarations and functions for Text Editor.
  5. **
  6. **     Copyright (c) 1992-1994 by Segue Software, Inc.
  7. **     All Rights Reserved.    
  8. */
  9.  
  10. /*******************************************************************************
  11. **                                                                            **
  12. **                         MENU ITEM DECLARATIONS                             **
  13. **                                                                            **
  14. *******************************************************************************/
  15.  
  16. window MainWin TextEditor
  17. {
  18.    tag "[TextEdit]Text Editor - *";
  19.    mac   tag "#1";
  20.   
  21.    SysMenu SysMenu
  22.    {
  23.       mac MenuItem    TextEditor               { tag "Text*Edit*";             }
  24.    }    
  25.  
  26.    Menu File
  27.    {
  28.       tag "File";
  29.  
  30.       MenuItem        New                      { tag "New";                    }
  31.       MenuItem        Open                     { tag "Open";                   }
  32.       MenuItem        Save                     { tag "Save";                   }
  33.       MenuItem        SaveAs                   { tag "Save As";                }
  34.       MenuItem        Exit                     { tag "Exit";
  35.                                                  mac tag "Quit";               }
  36.    }
  37.  
  38.    Menu Edit
  39.    {
  40.       tag "Edit";
  41.  
  42.       MenuItem        Undo                     { tag "Undo";                   }
  43.       MenuItem        Cut                      { tag "Cut";                    }
  44.       MenuItem        Copy                     { tag "Copy";                   }
  45.       MenuItem        Paste                    { tag "Paste";                  }
  46.       MenuItem        Delete                   { tag "Delete";
  47.                                                  mac tag "Clear";              }
  48.    }
  49.  
  50.    Menu Search
  51.    {
  52.       tag "Search";
  53.  
  54.       MenuItem        Find                     { tag "Find";                   }
  55.       MenuItem        FindNext                 { tag "Find Next";              }
  56.       MenuItem        Replace                  { tag "Replace";                }
  57.       MenuItem        GotoLine                 { tag "Goto Line";              }
  58.    }
  59.  
  60.    Menu Help
  61.    {
  62.       tag "Help";
  63.  
  64.       MenuItem        About                    { tag "About";                  }
  65.    }
  66.  
  67.    mac AppleMenu Help
  68.    {
  69.       MenuItem        About                    { tag "About";                  }
  70.    }
  71.    
  72.    TextField          Document                 { tag "#1";                     }
  73. }
  74.  
  75. /*******************************************************************************
  76. **                                                                            **
  77. **                         DIALOG BOX DECLARATIONS                            **
  78. **                                                                            **
  79. *******************************************************************************/
  80.  
  81. window DialogBox Open
  82. {
  83.    msw   tag "Open";
  84.    mac   tag "#1";
  85.    motif tag "File Open";
  86.    msw   parent TextEditor;
  87.    motif parent TextEditor;
  88.  
  89.    motif StaticText   FilterText               { tag "Filter";                 }
  90.    motif TextField    Filter                   { tag "Filter";                 }
  91.    StaticText         FileNameText             { tag "File Name:";
  92.                                                  motif tag "Selection";        }
  93.    TextField          FileName                 { tag "File Name:";
  94.                                                  motif tag "Selection";        }
  95.    ListBox            Files                    { tag "#1";                     }
  96.    PushButton         OK                       { tag "OK";     
  97.                                                  mac tag "Open";               }
  98.    PushButton         Cancel                   { tag "Cancel";                 }
  99.    motif PushButton   FilterButton             { tag "Filter";                 }
  100. }
  101.  
  102. window DialogBox SaveAs
  103. {
  104.    msw   tag "Save As";
  105.    mac   tag "#1";
  106.    motif tag "File Save As";
  107.    msw   parent TextEditor;
  108.    motif parent TextEditor;
  109.  
  110.    motif StaticText   FilterText               { tag "Filter";                 }
  111.    motif TextField    Filter                   { tag "Filter";                 }
  112.    StaticText         FileNameText             { msw tag "File Name:"; 
  113.                                                  mac tag "Save As:"; 
  114.                                                  motif tag "Selection";        }
  115.    TextField          FileName                 { msw tag "File Name:"; 
  116.                                                  mac tag "#1";
  117.                                                  motif tag "Selection";        }
  118.    ListBox            Files                    { tag "#1";                     }
  119.    PushButton         OK                       { tag "OK";     
  120.                                                  mac tag "Save";               }
  121.    PushButton         Cancel                   { tag "Cancel";                 }
  122.    motif PushButton   FilterButton             { tag "Filter";                 }
  123. }
  124.  
  125. window DialogBox Find
  126. {
  127.    tag "Find";
  128.    msw   parent TextEditor;
  129.    motif parent TextEditor;
  130.  
  131.    StaticText         FindWhatText             { tag "Find What:";             }
  132.    TextField          FindWhat                 { tag "Find What:";             }
  133.    StaticText         DirectionText            { tag "Direction";              }
  134.    RadioButton        Up                       { tag "Up";                     }
  135.    RadioButton        Down                     { tag "Down";                   }
  136.    PushButton         FindNext                 { tag "Find Next";              }
  137.    PushButton         Cancel                   { tag "Cancel";
  138.                                                  mac tag "Done";               }
  139. }
  140.  
  141. window DialogBox Replace
  142. {
  143.    tag "Replace";
  144.    msw   parent TextEditor;
  145.    motif parent TextEditor;
  146.  
  147.    StaticText         FindWhatText             { tag "Find What:";             }
  148.    TextField          FindWhat                 { tag "Find What:";             }
  149.    StaticText         ReplaceWithText          { tag "Replace With:";          }
  150.    TextField          ReplaceWith              { tag "Replace With:"; 
  151.                                                  motif tag "#2";               }
  152.    StaticText         DirectionText            { tag "Direction";              }
  153.    RadioButton        Up                       { tag "Up";                     }
  154.    RadioButton        Down                     { tag "Down";                   }
  155.    PushButton         FindNext                 { tag "Find Next";              }
  156.    PushButton         Replace                  { tag "Replace";                }
  157.    PushButton         ReplaceAll               { tag "Replace All";            }
  158.    PushButton         Cancel                   { tag "Cancel";  
  159.                                                  mac tag "Done";               }
  160. }
  161.  
  162. window DialogBox GotoLine
  163. {
  164.    tag "Goto Line";
  165.    msw   parent TextEditor;
  166.    motif parent TextEditor;
  167.  
  168.    StaticText         LineText                 { tag "Line:";                  }
  169.    TextField          Line                     { tag "Line:";                  }
  170.    PushButton         OK                       { tag "OK";                     }
  171.    PushButton         Cancel                   { tag "Cancel";                 }
  172. }
  173.  
  174. window DialogBox About
  175. {
  176.    tag "About";
  177.    mac   tag "#1";
  178.    msw   parent TextEditor;
  179.    motif parent TextEditor;
  180.  
  181.    StaticText         TextEditorText           { tag "Text Editor";            }
  182.    PushButton         OK                       { tag "OK";                     }
  183. }
  184.  
  185. /*******************************************************************************
  186. **                                                                            **
  187. **                         ADDITIONAL DECLARATIONS                            **
  188. **                                                                            **
  189. *******************************************************************************/
  190.  
  191. window DialogBox MessageBox
  192. {
  193.   msw   tag "../[DialogBox]#1";
  194.   mac   tag "#1";
  195.   motif tag "[DialogBox]#1";
  196.   motif parent TextEditor;
  197.    
  198.   StaticText          Message                  { tag "#1";                     }
  199.   PushButton          No                       { tag "No";                     }
  200. }
  201.  
  202. /******************************************************************************/
  203.  
  204. ScriptEnter ()
  205. {
  206.    if (GetGUIType () == GT_MAC)                  // set Mac current directory 
  207.       SYS_SetDir ("{SYS_GetDrive ()}:QAPDemo:Demo");
  208. }
  209.  
  210. /******************************************************************************/
  211.  
  212. StartEditor ()
  213. {
  214.    // start the editor and makes it the active window
  215.  
  216.    string sPath;    
  217.    switch (GetGUIType ()) {
  218.       case GT_MSW:   sPath = "{SYS_GetDrive ()}:\qapdemo\demo\textedit.exe";
  219.       case GT_MAC:   sPath = "{SYS_GetDrive ()}:QAPDemo:Demo:TextEdit";
  220.       case GT_MOTIF: sPath = "{SYS_GetEnv ("SEGUE_APPS")}/qapdemo/demo/textedit";
  221.    }    
  222.     
  223.    APP_Start (sPath);                             // start the application
  224.  
  225.    if (GetGUIType () == GT_MAC) {                 // if running on a Mac,
  226.      if (TextEditor.SysMenu.TextEditor.Exists ())
  227.          TextEditor.SysMenu.TextEditor.Pick ();   // make it the active window  
  228.      }
  229.    else                                           // otherwise,     
  230.       if (TextEditor.Exists ())                   // if Text Editor exists
  231.          TextEditor.SetActive ();                 // make it the active window      
  232. }
  233.  
  234. /******************************************************************************/
  235.  
  236. EndEditor ()
  237. {
  238.    // exit the application
  239.  
  240.    WND_SetTrap ("[StaticText]Save File -*", "[PushButton]NO");
  241.    
  242.    APP_Exit (TextEditor.AppId);                   // exit the application
  243.  
  244.    string sFile;                                  // determine filename by GUI type
  245.    if (GetGUIType () == GT_MOTIF) 
  246.       sFile = "/tmp/temp.txt";                    // set variable
  247.    else
  248.       sFile = "temp.txt";
  249.  
  250.    if (SYS_FileExists (sFile))                    // clean up the temp.t file
  251.        SYS_RemoveFile (sFile);                    // if it exists
  252. }
  253.  
  254.  
  255.